package com.jp.knowledge.model;

import android.os.Parcel;
import android.os.Parcelable;

import org.xutils.db.annotation.Table;

/**
 * Created by jiayen on 16/10/14.
 * 话题实体
 */
@Table(name = "TopicInfo")
public class TopicInfo extends BaseDb implements Parcelable{
    /**
     * topicId : db8fc463-3fba-4809-bf6a-13b0811feeaf
     * count : 1
     * userName : jian
     * portrait : null
     * userId : e7ceb2d5-c85f-4fee-97c1-4635ad85c187
     * content : 5wew
     * discuss : 2
     */

    private String topicId;
    private int count;
    private String userName;
    private String portrait;
    private String userId;
    private String content;
    private int discuss;

    private int isCollection;
    private String commentId;
    private int praiseNum;
    private int isPraise;

    public int getIsCollection() {
        return isCollection;
    }

    public void setIsCollection(int isCollection) {
        this.isCollection = isCollection;
    }

    public String getCommentId() {
        return commentId;
    }

    public void setCommentId(String commentId) {
        this.commentId = commentId;
    }

    public int getPraiseNum() {
        return praiseNum;
    }

    public void setPraiseNum(int praiseNum) {
        this.praiseNum = praiseNum;
    }

    public int getIsPraise() {
        return isPraise;
    }

    public void setIsPraise(int isPraise) {
        this.isPraise = isPraise;
    }

    public void setTopicId(String topicId) {
        this.topicId = topicId;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public void setPortrait(String portrait) {
        this.portrait = portrait;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public void setDiscuss(int discuss) {
        this.discuss = discuss;
    }

    public String getTopicId() {
        return topicId;
    }

    public int getCount() {
        return count==0?discuss:count;
    }

    public String getUserName() {
        return userName;
    }

    public String getPortrait() {
        return portrait;
    }

    public String getUserId() {
        return userId;
    }

    public String getContent() {
        return content;
    }

    public int getDiscuss() {
        return discuss;
    }


//    @Column(name="topicId")
//    private String topicId;
//    @Column(name="userName")
//    private String userName;
//    @Column(name="portrait")
//    private String portrait;
//    @Column(name="count")
//    private int count;
//
//    private List<String> tags;
//
//    @Column(name="tags")
//    private String tag;
//
//    @Column(name="infoId")
//    private String infoId;
//
//    public String getTopicId() {
//        return topicId;
//    }
//
//    public void setTopicId(String topicId) {
//        this.topicId = topicId;
//    }
//
//    public String getUserName() {
//        return userName;
//    }
//
//    public void setUserName(String userName) {
//        this.userName = userName;
//    }
//
//    public String getPortrait() {
//        return portrait;
//    }
//
//    public void setPortrait(String portrait) {
//        this.portrait = portrait;
//    }
//
//    public int getCount() {
//        return count;
//    }
//
//    public void setCount(int count) {
//        this.count = count;
//    }
//
//    public String getTag() {
//        return tag;
//    }
//
//    public void setTag(String tag) {
//        this.tag = tag;
//    }
//    public void setTag(List<String> tags) {
//        if(tags==null)return;
//        StringBuilder sb=new StringBuilder();
//        for (String t:tags){
//            sb.append(",").append(t);
//        }
//        this.tag = sb.toString().substring(1);
//    }
//
//    public List<String> getTags() {
//        if((tags==null||tags.size()==0)&&tag!=null){
//            tags= Arrays.asList(tag.split(","));
//        }
//        return tags;
//    }
//
//    public void setTags(List<String> tags) {
//        this.tags = tags;
//        StringBuilder sb=new StringBuilder();
//        for (String t:tags){
//            sb.append(",").append(t);
//        }
//        this.tag=sb.toString().substring(1);
//    }
//
//
//    public TopicInfo() {
//    }
//
//    public void setInfoId(String infoId) {
//        this.infoId = infoId;
//    }
//
//    public String getInfoId() {
//        return infoId;
//    }
//
//    @Override
//    public String toString() {
//        return "TopicInfo{" +
//                "topicId='" + topicId + '\'' +
//                ", userName='" + userName + '\'' +
//                ", portrait='" + portrait + '\'' +
//                ", count=" + count +
//                ", tags=" + tags +
//                '}';
//    }
//
//    @Override
//    public int describeContents() {
//        return 0;
//    }
//
//    @Override
//    public void writeToParcel(Parcel dest, int flags) {
//        dest.writeString(this.topicId);
//        dest.writeString(this.userName);
//        dest.writeString(this.portrait);
//        dest.writeInt(this.count);
//        dest.writeStringList(this.tags);
//        dest.writeString(this.tag);
//        dest.writeString(this.infoId);
//    }
//
//    protected TopicInfo(Parcel in) {
//        this.topicId = in.readString();
//        this.userName = in.readString();
//        this.portrait = in.readString();
//        this.count = in.readInt();
//        this.tags = in.createStringArrayList();
//        this.tag = in.readString();
//        this.infoId = in.readString();
//    }
//
//    public static final Creator<TopicInfo> CREATOR = new Creator<TopicInfo>() {
//        public TopicInfo createFromParcel(Parcel source) {
//            return new TopicInfo(source);
//        }
//
//        public TopicInfo[] newArray(int size) {
//            return new TopicInfo[size];
//        }
//    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.topicId);
        dest.writeInt(this.count);
        dest.writeString(this.userName);
        dest.writeString(this.portrait);
        dest.writeString(this.userId);
        dest.writeString(this.content);
        dest.writeInt(this.discuss);
        dest.writeInt(this.isCollection);
        dest.writeString(this.commentId);
        dest.writeInt(this.praiseNum);
        dest.writeInt(this.isPraise);
    }

    public TopicInfo() {
    }

    protected TopicInfo(Parcel in) {
        this.topicId = in.readString();
        this.count = in.readInt();
        this.userName = in.readString();
        this.portrait = in.readString();
        this.userId = in.readString();
        this.content = in.readString();
        this.discuss = in.readInt();

        this.isCollection = in.readInt();
        this.commentId = in.readString();
        this.praiseNum = in.readInt();
        this.isPraise = in.readInt();

    }

    public static final Creator<TopicInfo> CREATOR = new Creator<TopicInfo>() {
        public TopicInfo createFromParcel(Parcel source) {
            return new TopicInfo(source);
        }

        public TopicInfo[] newArray(int size) {
            return new TopicInfo[size];
        }
    };


    @Override
    public String toString() {
        return "TopicInfo{" +
                "topicId='" + topicId + '\'' +
                ", count=" + count +
                ", userName='" + userName + '\'' +
                ", portrait='" + portrait + '\'' +
                ", userId='" + userId + '\'' +
                ", content='" + content + '\'' +
                ", discuss=" + discuss +
                '}';
    }
}
